package com.yj.music_center;

import androidx.annotation.NonNull;

import com.yj.music_center.util.audio.AudioUtil;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;

public class MethodCallHandlerImpl implements MethodChannel.MethodCallHandler {
    @Override
    public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
        switch (call.method){
            case "getPlatformVersion":
                result.success("Android " + android.os.Build.VERSION.RELEASE);
                break;
            case "switchMusicOn":
                AudioUtil.getInstance().playOrPauseMusic();
                result.success(true);
                break;
            case "isMusicOn":
                result.success(AudioUtil.getInstance().isMusicActive());
                break;
            case "nextMusic":
                AudioUtil.getInstance().nextMusic();
                result.success(true);
                break;
            case "lastMusic":
                AudioUtil.getInstance().lastMusic();
                result.success(true);
                break;
            default:
                result.notImplemented();
                break;
        }
    }
}
